#include <bits/stdc++.h>
using namespace std;

int a[1000005], ans[100005], n, maxn = 0;

void dfs(int dep)
{
    if (dep == n + 1)
    {
        int sum = 0;
        for (int i = 1; i <= n; i ++)
        {
            for (int j = i - 1; j >= 1; j --)
            {
                if (ans[i] == ans[j])
                {
                    if (a[i] == a[j]) sum += a[i];
                    break;
                }
            }
        }
        maxn = max(maxn, sum);
        return;
    }

    ans[dep] = 1;
    dfs(dep + 1);
    ans[dep] = 2;
    dfs(dep + 1);
}

int main()
{
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    int T;
    cin >> T;
    while (T --)
    {
        memset(ans, 0, sizeof ans);
        maxn = 0;
        cin >> n;
        for (int i = 1; i <= n; i ++)
        {
            cin >> a[i];
        }

        dfs(1);
        cout << maxn << "\n";
    }
    return 0;
}
